<?php

class FrontController extends Controller {

    public function actionIndex() {
        $this->redirect(array('front/search'));
    }

    public function actionSearch() {
        $model = new RuanganRapat('search');
        $model->unsetAttributes();  // clear any default values
        if (isset($_GET['RuanganRapat'])) {
            $model->attributes = $_GET['RuanganRapat'];
            
            if ($model->time_start != '' && $model->time_end != '') {
                $model->status = "available $model->time_start $model->time_end";
            }
            
            if ($model->participant != '') {
                $model->capacity = '>= ' . $model->participant;
            }
        }

        $this->render('search', array('model' => $model, 'dataProvider' => $model->search($model->date)));
    }

    public function actionMeetingList() {
        $model = new RapatRequest('search');
        $model->unsetAttributes();
        if (isset($_GET['RapatRequest'])) {
            $model->attributes = $_GET['RapatRequest'];
        }

        $this->render('meetingList', array('model' => $model, 'dataProvider' => $model->searchApprovedRequest()));
    }

}